package cs340omega;

/**
 * This class Stores and verifies a Port
 * @author rpadilla
 *
 */
public class Port implements java.io.Serializable
{

	private static final long serialVersionUID = 1L;
	private final int MAXPORTS = 65535;
	private int port;
	/**
	 * Constructor that verifies the inputed Port and stores it.
	 * @param int representation of Port to be stored
	 * @throws NumberFormatException
	 */
	public Port(int _port)
	{	
		if(_port > 0 && _port <= MAXPORTS)
		{
			this.port = _port;
		} 
		else
		{
			throw new NumberFormatException("Port number must be within " 
					+ "the range of 0-65535 inclusive");
		}
	}
	/**
	 * Returns the stored Port.
	 * @return Stored Port
	 */
	public int getPort()
	{
		return this.port;
	}
	/**
	 * Generates Hash Code for this Port
	 * @return The Port number as its own unique hash code.
	 */
	public int hashCode()
	{
		return port;
	}
}
